﻿using System;
using System.Collections.Generic;
using System.Linq;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YJKRevitDimensionText.DimCreator;

namespace YJKRevitDimension.AutoDimensionTest
{
	[Transaction(TransactionMode.Manual)]
	internal class CmdDimAvoid : IExternalCommand
	{
		public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
		{
			Document document = commandData.Application.ActiveUIDocument.Document;
			this.m_uidoc = commandData.Application.ActiveUIDocument;
			List<Dimension> inputDims = (from d in new FilteredElementCollector(document, document.ActiveView.Id).OfClass(typeof(Dimension)).OfCategory(BuiltInCategory.OST_Dimensions)
			select d as Dimension).ToList<Dimension>();
			new List<Curve>();
			DimAvoidManager.TryAutoAvoidElementForHorizontal(document, inputDims);
			return Autodesk.Revit.UI.Result.Succeeded;
		}

		private UIDocument m_uidoc;
	}
}
